package com.example.designpatterns.SimpleFactory;

/**
 * @author HUAWEI
 */
public class OperationFactory {
    /**
     * 根据传入的运算符返回对应的对象
     * @param operator
     * @return
     */
    public static Operation createOperation(String operator) {
        Operation operation = null;
        switch (operator) {
            case "+":
                operation = new Add();
                break;
            case "-":
                operation = new Sub();
                break;
            case "*":
                operation = new Mul();
                break;
            case "/":
                operation = new Div();
                break;
            default:
                operation = null;
        }
        return operation;
    }
}
